package com.yunxin.core.infra.persistence.repository.product;

import com.yunxin.core.domain.model.product.ProductUnitPriceConfigVersion;
import com.yunxin.core.domain.model.product.ProductUnitPriceConfigVersionRepository;
import com.yunxin.core.infra.persistence.converter.ProductConverter;
import com.yunxin.core.infra.persistence.entity.product.ProductUnitPriceConfigVersionDO;
import com.yunxin.core.infra.persistence.mapper.product.ProductUnitPriceConfigVersionExtendMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

/**
 * @author zero°
 * @since 2023-07-13
 */
@Repository
@RequiredArgsConstructor
public class ProductUnitPriceConfigRepositoryVersionImpl implements ProductUnitPriceConfigVersionRepository {

    private final ProductUnitPriceConfigVersionExtendMapper productUnitPriceConfigVersionExtendMapper;

    private final ProductConverter productConverter;

    @Override
    public boolean saveProductUnitPriceConfigVersion(ProductUnitPriceConfigVersion productUnitPriceConfigVersion) {
        ProductUnitPriceConfigVersionDO productUnitPriceConfigVersionDO = productConverter.formProductUnitPriceConfigVersion(productUnitPriceConfigVersion);
        int count = productUnitPriceConfigVersionExtendMapper.insertSelective(productUnitPriceConfigVersionDO);
        return count > 0;
    }

}
